<%- map = GoogleMap.new -%>
<%- 
	current_user.spots.each do |spot| 
		map.markers << GoogleMapMarker.new(:map => map, 
	                                   :lat => spot.latitude.to_f, 
	                                   :lng => spot.longitude.to_f,
	                                   :html => (render :partial => 'inside_baloon', :locals => {:spot => spot }))
	end
	if map.markers.empty?
		map.markers << GoogleMapMarker.new(:map => map, 
	                                   :lat => 32.74207489599587, 
	                                   :lng => 129.87160563468933,
	                                   :html => '')
	end
-%>


<script type="text/javascript">
//<![CDATA[
var custom_google_map = null;
function customize_google_map(){
	  var initialize_without_customize = window.onload;
	  window.onload = function(){
	  	initialize_without_customize();
		
		// custom_google_map = google_map;
		GEvent.addListener(google_map, 'click', function(overlay, point) {
			  if (point) {
		        $("spot_latitude").value = point.y;
		        $("spot_longitude").value = point.x;
		      }
		    });
	  }
}
//]]>
</script>

  <%= map.to_html{"customize_google_map();"} %>
  <div style="width: 800px; height: 600px;">
    <%= map.div %>
  </div>

<%- form_tag do -%>
	<div>
		<label id='spot_name'>スポット</label>
		<%= text_field 'spot', 'name', :id => 'spot_name', :size => 80 %>
		<%= text_field 'spot', 'latitude', :class => 'numeric', :id => 'spot_latitude' %>
		<%= text_field 'spot', 'longitude', :class => 'numeric', :id => 'spot_longitude' %>
	</div>
	<div>
		<%= text_area 'spot', 'comment', :cols => 80, :rows => 4 %>
	</div>
	<input type="submit" value="                &raquo; スポットを追加                ">
<%- end -%>
